from greenlet import greenlet

"""
    方式一：利用greenlet模块实现
    缺点是需要手动明文调用switch切换
"""

def func1():
    print('1')
    gr2.switch()
    print('2')
    gr2.switch()


def func2():
    print('3')
    gr1.switch()
    print('4')


gr1 = greenlet(func1)
gr2 = greenlet(func2)
gr1.switch()
